export const myDate = new Date()
export const myYear = myDate.getFullYear() //获取完整的年份(4位,1970-????)
export const myMonth = myDate.getMonth() + 1 //获取当前月份(0-11,0代表1月)
export const myToday = myDate.getDate() //获取当前日(1-31)
export const myDay = myDate.getDay() //获取当前星期X(0-6,0代表星期天)
export const myHour = myDate.getHours() //获取当前小时数(0-23)
export const myMinute = myDate.getMinutes() //获取当前分钟数(0-59)
export const mySecond = myDate.getSeconds() //获取当前秒数(0-59)
export const week = ['星期日', '星期一', '星期二', '星期三', '星期四', '星期五', '星期六']


export const fillZero = str => {
  let realNum
  if (str < 10) {
    realNum = '0' + str;
  } else {
    realNum = str;
  }
  return realNum;
}

export const nowTime = () => {
  return myYear + '年' + fillZero(myMonth) + '月' + fillZero(myToday) + '日 '
}

export const getTime = () => {
  const week = ['星期日', '星期一', '星期二', '星期三', '星期四', '星期五', '星期六']

  return myYear + '年' + fillZero(myMonth) + '月' + fillZero(myToday) + '日 ' + ' ' + fillZero(myHour) + ':' +
    fillZero(myMinute) + ':' + fillZero(mySecond) + ' ' + week[myDay]
}
